package com.itdev.matcherapp.android;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;

import com.itdev.matcherapp.android.fakeservice.ContentCategoeryBean;
import com.itdev.matcherapp.android.fakeservice.ServiceFaky;

public class AddingContent extends Activity {
	private Spinner spinnerCategoeryName; 
	private Button buttonOK;
	private Button buttonCancel;
	@Override
	protected void onCreate(Bundle icicle) {
		super.onCreate(icicle);
		setContentView(R.layout.addingcontent);
		spinnerCategoeryName = (Spinner) findViewById(R.id.addingcontent_spinnerContent);
		spinnerCategoeryName.setAdapter(new ContentCategoerySpinnerAdapter(this));
		buttonOK = (Button) findViewById(R.id.addingcontent_buttonAdd);
		buttonCancel = (Button) findViewById(R.id.addingcontent_buttonCancel);
	}
}

class ContentCategoerySpinnerAdapter extends BaseAdapter{
	private Context context;
	private List<ContentCategoeryBean> contentCategoeryList = new ArrayList<ContentCategoeryBean>();
	public ContentCategoerySpinnerAdapter(Context context){
		this.context = context;
		contentCategoeryList = ServiceFaky.getContentCategoeryList();
	}
	
	public int getCount() {
		return contentCategoeryList.size();
	}

	public Object getItem(int position) {
		return contentCategoeryList.get(position);
	}

	public long getItemId(int position) {
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		ContentCategoeryBean content = (ContentCategoeryBean) getItem(position);
		TextView textView = new TextView(context);
		textView.setText(content.getContentCategoeryName());
		textView.setTextColor(Color.BLACK);
		return textView;
	}	
}